Repository navigation
feat(hip): Inkling 2's attention at each layer's bias extent, tiny-inkling2-mini's 128 and 256 beside Mini's 1,024 - #5499
Merged
Conversation
AbrahamCete
marked this pull request as ready for review
November 29, 2026 10:36
ashhart
force-pushed
the
feat/hip-inkling2-attn-extent
branch
from
November 30, 2026 02:33
20d8275 to
150b3c9
Compare
Owner
|
READY to land on this head. Reviewed, with one device check asked: we ran the full Inkling 2 HIP kernel contract on a gfx1151 GPU at this head and at main. This head adds no failure over main beyond the planted controls going red, and the two new kernels' resource-limit records now match their compiled sizes.
|
ashhart
force-pushed
the
feat/hip-inkling2-attn-extent
branch
from
November 30, 2026 22:27
150b3c9 to
718a050
Compare
Owner
|
READY to land on this head. Checked at this head: the reviewed change re-placed on current main, keeping every main row in the conflicting files; this head's CI passed.
|
… per call Call.extent is a layer's relative-bias extent: the window on local layers, rel_extent on global ones. It defaults to 1,024, the extent the reference had fixed, so CUDA's attention contracts compile unchanged and keep their want and tol bits. The bias table rows are the call's extent long, and global keys past it gather by ring slot with no bias. A test checks a global row at extent 256 and a sliding row at window and extent 128 (tiny-inkling2-mini's two layers): each on its own table equals extent 1,024 on that table padded with zeros, to float64 rounding (gate 4's replay bit for bit), and the bias past 256 moves the row.
… and 128 beside Mini's 1,024 tf_ink2_rel_table is one macro body built at three extents: Mini's 1,024 (the same symbol and code) and tiny-inkling2-mini's 256 (global layers) and 128 (local) as tf_ink2_rel_table_e256 and tf_ink2_rel_table_e128. Each reads rel_logits_proj as [16][extent] and writes a row of 1,024 distances, zeros past its extent, so the attention kernels read one table layout at every extent and keep their code; tile.hpp's kExtent is kTabRow, the row length. relTable takes the layer's extent and launches its kernel, refusing any other before a launch (UnsupportedRelExtent). layerExtent reads a layer's extent from the parsed config (the window on local layers, rel_extent on global ones) and refuses one with no kernel by name, with config.Why naming the layer, its extent and the three built. The contract registers both new tables at tiny-mini's 4 heads, each with a control reading rel_logits_proj a column late, and their gate-5 records come from the code objects. Mini's registrations and records are unchanged.
…ds, window and extents The HIP attention contract's fills, prep and rows take a checkpoint's geometry (fill.Model: query and key heads, window, rel_extent, n_floor). Mini's registrations keep their names, shapes and inputs. Beside them, tiny-inkling2-mini's run at 4/2 heads: prep (sliding, global and three streams), sliding rows at window 128 with edges at 127 to 129 keys and across a 256-key chunk, global fold, split and prompt rows past extent 256 with edges at 255 to 257 keys and across 1,024-key sub-chunks and 16,384-key chunks, three streams in one launch against each alone, the split and prompt against the fold, and the exact-P rows. The reference reads each call's table at its extent; the device gets it padded to 1,024 distances. Gate 4's values cancel over a sliding layer's window, so a 128-key window is its own period; there the second 32 of every 64 keys are 32 times larger, so 32-lane fp16 sums lose bits too, and a host test pins fp32 exact with fp16 and bf16 missing. Two more controls go red: global rows given bias past extent 256, and a window one key past 128.
…loat64, CUDA's default bits pinned, HIP extent refusals
ashhart
force-pushed
the
feat/hip-inkling2-attn-extent
branch
from
December 1, 2026 02:26
718a050 to
130ab19
Compare
Owner
|
Thank you @AbrahamCete. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
This was referenced Dec 1, 2026
AbrahamCete
added a commit
to AbrahamCete/TensorFold
that referenced
this pull request
Dec 1, 2026
…tract launchers Zig 0.17 requires each source file to belong to one module. After ashhart#5012, ashhart#4994, ashhart#5499 and ashhart#5728, inkling2_hip, inkling2_loop_hip, inkling2_experts_hip and the stream state targets all imported config.zig directly, causing duplicate module ownership inside tf-hip-kernel-contract. Group the shared Inkling 2 family files (config, plan, names, names_test, loop, kept_state, hip_weights, config_test) into zig/src/families/inkling2/hip_family.zig and pass one inkling2_family module into the Inkling 2 HIP launcher and state modules.
ashhart
pushed a commit
to AbrahamCete/TensorFold
that referenced
this pull request
Dec 1, 2026
…tract launchers Zig 0.17 requires each source file to belong to one module. After ashhart#5012, ashhart#4994, ashhart#5499 and ashhart#5728, inkling2_hip, inkling2_loop_hip, inkling2_experts_hip and the stream state targets all imported config.zig directly, causing duplicate module ownership inside tf-hip-kernel-contract. Group the shared Inkling 2 family files (config, plan, names, names_test, loop, kept_state, hip_weights, config_test) into zig/src/families/inkling2/hip_family.zig and pass one inkling2_family module into the Inkling 2 HIP launcher and state modules.
ashhart
pushed a commit
that referenced
this pull request
Dec 1, 2026
…tract launchers Zig 0.17 requires each source file to belong to one module. After #5012, #4994, #5499 and #5728, inkling2_hip, inkling2_loop_hip, inkling2_experts_hip and the stream state targets all imported config.zig directly, causing duplicate module ownership inside tf-hip-kernel-contract. Group the shared Inkling 2 family files (config, plan, names, names_test, loop, kept_state, hip_weights, config_test) into zig/src/families/inkling2/hip_family.zig and pass one inkling2_family module into the Inkling 2 HIP launcher and state modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
HIP1's attention (#4633) fixes the relative-bias extent at 1,024, so it cannot serve
hf-internal-testing/tiny-inkling2-mini, whose local layers have an extent of 128 (the window) and whose global layers have 256. This makes HIP1 follow each layer's extent, as asked on #4265 (issuecomment-7215811144), and adds tiny-mini's heads, window and extents to the HIP attention contract. Mini's kernels and outputs are unchanged.core/contract/inkling2_attn_ref.zigtakes the extent per call:Call.extent, 1,024 by default. CUDA's callers and cases are unchanged, and there is no separate HIP reference.tf_ink2_rel_tablestays Mini's 1,024 kernel, with the same symbol and machine code;tf_ink2_rel_table_e256andtf_ink2_rel_table_e128are new compile-time instances. Each writes rows of 1,024 distances with zeros past its extent, so the four attention kernels read one layout at every extent and do not change.relTable()launches the extent's kernel and refuses any other extent witherror.UnsupportedRelExtent, before a launch.layerExtent(text, i, why)reads a layer's extent from the parsed config and names the refusal: "layer {i}'s relative-bias extent {e} has no HIP bias table: tf_ink2_rel_table is built at extents 1024, 256 and 128".fixtures/tiny_mini_config.jsonfrom test(inkling2): tiny-inkling2-mini config and model header fixtures with parse, weight map and visit plan tests #5369.Why compile-time extents: templating the four attention kernels would add 8 kernels to cover, and a run-time extent would change Mini's machine code. Writing zeros past the extent keeps one table layout for all three.
layerExtentat load, so a refusal names its layer before any launch. HIP4's widths are on perf(hip): Inkling 2's loop kernels (cross-pass message and message gate) at hidden 2,304 and 256 under named HIP baselines #5012, and the HIP3 rebuild remains.main51fee3c. Commits:atc overlap --json(ATC 0.9.6, 2026-11-28 10:06Z, againstmain51fee3c): 9 overlaps, 7 clean. ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522 and ricursive: speed up Ripple-65B on two GB10s #2523 conflict indocs/kernel-contract.md: ricursive: speed up Ripple-65B on two GB10s #2523 conflicts withmainthere without this branch, and ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522 only with this branch; whichever lands second rebases. The run is incomplete (limits on pull requests, their files and time).Checks on this head
main51fee3c.python3 tools/zig/lean_check.py, on the base and on this head: 93 and 93, 0 new.zig build test-inkling2-hip-host -Dhip=true: 76 of 78 passed, 2 skipped.zig build test-inkling2-cuda-host62 of 62;zig build test-inkling2-host61 of 66, 5 skipped;zig build test-kernel-contract365 of 365.zig build teston the same tree: 14,489 of 14,588 passed, 98 skipped, 1 failed. The failure isstage_hip_test"every staged call on HIP memory equals the reference, whole and in parts", which fails onmainon this machine as well.zig build test -Dhip=trueon the same tree: 1,604 of the 1,628 tests it ran passed, 23 skipped, and the samestage_hip_testfailed.extent) and the HIP host tests give 6 compile errors. A reference default of 1,000 instead of 1,024 turns 5 tests red, the new ones among them.zig fmt --check build.zig zigandgit diff --check: clean.tf_ink2_prep,tf_ink2_rel_table,tf_ink2_attn,tf_ink2_attn_fold,tf_ink2_attn_prompt,tf_ink2_merge) are identical and the two new tables are added. The tool also flagsaffine_dot2_blockinstantiations intiles/dot2.hip, which this branch does not touch and in which two builds of the same tree differ.Call.extentexisted.simulatebit-equal. That check is now a test, with one-off-the-extent controls that go red.zig-windowsfails atzig build -Dfixed-cpu compile-native-cuda-windowswith "no module named 'flashnext_memory' available within module 'checkpoint_cli'" inzig/src/cli/tfq3_validate.zig. That failure is inherited: this branch touches no build or CLI file, and flashnext cuda: size the rows-store staging permit from the served window #5501 and flashnext tfq3: route B=2..16 decode windows in parallel and build the dedup lists in parallel, bit for bit #5506 fail the same step with the same error.Receipt
n/a: no engine or server calls these kernels yet. The kernel contract below is the evidence.
Kernel contract, only when a GPU kernel is new or changed
Kernels registered with the contract (
tf-hip-kernel-contract image inkling2):tf_ink2_rel_table_e256andtf_ink2_rel_table_e128, besidetf_ink2_rel_table(Mini's 1,024), which they do not replace. Each output is held to the shared FP64 reference at the call's extent, within the contract's bound for fp32 sums rounded to bf16; the tables have no bit-exact oracle.A planted control for each new kernel, each its own kernel, red at
shapes: each new table readingrel_logits_projone column late, global rows given a bias past extent 256, and a window one key past 128.Each backend's
SUMMARYline and exit status (gfx1151, ROCm 10.1's hipcc, HIP 7.16):SUMMARY inkling2 HIP full: 27 kernels: 27 pass gates 1-4, 0 fail, 0 known findings; 12 controls: 12 red as planted, 0 missed; 0 limit problems; gates 209800 ms, limits 5 ms(exit 0), on a clean tree of this head. The base has 13 kernels and 8 controls.zig build hip-kernel-contract -Dhip-arch=gfx1151, before the rebase:SUMMARY gfx1151 224 kernels: 224 pass gates 1-4, 0 fail, 2 known findings; 78 controls: 78 red as planted, 0 missed; 2 limit problems; gates 869607 ms, limits 2971 ms(exit 1). The two limit problems aretf_moe_combine_gateandtf_vl_resize, whose records the base's limits audit also flags as stale.zig build hip-kernel-contract-limits: 11 problems on base and head, the same 11, none in the Inkling 2 groups. The two new records are current on all four chips.Chips I could not run: gfx1030, gfx1100 and gfx1201 (limits only), and every CUDA SM and Metal chip.
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (n/a: no engine)--drafter, no slower than without it, greedy and sampled. (n/a: no engine)